import { useStorage } from "@vueuse/core";

/**
 * localStorage缓存
 */
export function useLocalStorage() {
  const getStorage = (key) => {
    window.localStorage.getItem(key);
  };
  const setStorage = (key, value) => {
    window.localStorage.setItem(key, value);
  };
  const removeStorage = (key) => {
    window.localStorage.removeItem(key);
  };

  return {
    getStorage,
    setStorage,
    removeStorage,
  };
}

/**
 * sessionStorage缓存
 */
export function useSessionStorage() {
  const getStorage = (key) => {
    window.sessionStorage.getItem(key);
  };
  const setStorage = (key, value) => {
    window.sessionStorage.setItem(key, value);
  };
  const removeStorage = (key) => {
    window.sessionStorage.removeItem(key);
  };

  return {
    getStorage,
    setStorage,
    removeStorage,
  };
}
